<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection"
	content="telephone=no,email=no,date=no,address=no">
<title></title>
<link rel="stylesheet" type="text/css" href="../css/aui.css" />
<link rel="stylesheet" type="text/css"
	href="../css/aui-pull-refresh.css" />
<style type="text/css">
.aui-list .aui-list-item i.aui-iconfont {
	-webkit-align-self: center;
	align-self: center;
	font-size: 18px;
}
</style>
</head>
<body>
	<header class="aui-bar aui-bar-nav aui-bar-warning" id="aui-header">
	<a class="aui-pull-left" onclick="window.history.back(-1);"> <span
		class="aui-iconfont aui-icon-left"></span>
	</a>
	<div class="aui-title">客户详情</div>
	<a class="aui-pull-right"> </a> </header>

	<div class="aui-content aui-margin-b-15">
		<ul class="aui-list aui-form-list">
			<li class="aui-list-item">
				<div
					class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
					<div class="aui-btn aui-btn-primary aui-margin-l-5"
						onclick="visitOpen('${param.id}')">拜访</div>
					<div class="aui-btn aui-btn-primary aui-margin-l-5"
						onclick="recordOpen('${param.id}')">跟进</div>
					<div class="aui-btn aui-btn-primary aui-margin-l-5"
						onclick="contractOpen('${param.id}')">合同</div>
					<div class="aui-btn aui-btn-primary aui-margin-l-5"
						onclick="receivableOpen('${param.id}')">回款</div>
					<div class="aui-btn aui-btn-primary aui-margin-l-5"
						onclick="revisitOpen('${param.id}')">回访</div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">客户名称:</div>
					<div class="aui-list-item-input" id="customerName"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:</div>
					<div class="aui-list-item-input" id="sex"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机:</div>
					<div class="aui-list-item-input" id="mobileNumber"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">客户类型:</div>
					<div class="aui-list-item-input" id="customerType"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址:</div>
					<div class="aui-list-item-input" id="address"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						职&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;业:</div>
					<div class="aui-list-item-input" id="profession"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">公司名称:</div>
					<div class="aui-list-item-input" id="company"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">公司地址:</div>
					<div class="aui-list-item-input" id="companySite"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">客户来源:</div>
					<div class="aui-list-item-input" id="customerSource"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">出生日期:</div>
					<div class="aui-list-item-input" id="birthday"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						籍&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;贯:</div>
					<div class="aui-list-item-input" id="birthPlace"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">证件类型:</div>
					<div class="aui-list-item-input" id="idType"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">证件号码:</div>
					<div class="aui-list-item-input" id="idNumber"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						学&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;历:</div>
					<div class="aui-list-item-input" id="educationBackground"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">婚姻状况:</div>
					<div class="aui-list-item-input" id="maritalStatus"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">座机号码:</div>
					<div class="aui-list-item-input" id="phone"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">传真号码:</div>
					<div class="aui-list-item-input" id="facsimile"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">
						网&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址:</div>
					<div class="aui-list-item-input" id="url"></div>
				</div>
			</li>
			<li class="aui-list-item">
				<div class="aui-list-item-inner">
					<div class="aui-list-item-label">创建时间:</div>
					<div class="aui-list-item-input" id="createDate"></div>
				</div>
			</li>
		</ul>
	</div>
</body>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript">
	//初始方法
	$(function() {
		getPage(id);
	});

	//得到选择机会信息的id
	var id = '${id}';
	function getPage(id) {
		$.ajax({
					url : '${pageContext.request.contextPath}/appcrm/customerDetail.do?id='
							+ id,
					type : "POST",
					dataType : "json",
					success : function(data) {
						if (data.code == "0") {
							if (data.customer != "undefined") {
								var maritalStatus = "";
								var idType = "";
								var customerType = "";
								var educationBackground = "";
								var customerSource = "";
								if (data.customer.maritalStatus == 0) {
									maritalStatus = "未婚";
								} else if (data.customer.maritalStatus == 1) {
									maritalStatus = "已婚";
								} else if (data.customer.maritalStatus == 2) {
									maritalStatus = "离异";
								} else if (data.customer.maritalStatus == 3) {
									maritalStatus = "丧偶";
								}
								if (data.customer.idType == 0) {
									idType = "身份证";
								} else if (data.customer.idType == 1) {
									idType = "军警证";
								} else if (data.customer.idType == 2) {
									idType = "护照";
								} else if (data.customer.idType == 3) {
									idType = "其他";
								}
								if (data.customer.customerType == 0) {
									customerType += "自然人";
								} else if (data.customer.customerType == 1) {
									customerType += "老总";
								} else if (data.customer.customerType == 2) {
									customerType += "部门经理";
								} else if (data.customer.customerType == 3) {
									customerType += "部门主管";
								} else if (data.customer.customerType == 4) {
									customerType += "普通员工";
								} else if (data.customer.customerType == 5) {
									customerType += "其他";
								}
								if (data.customer.educationBackground == 0) {
									educationBackground = "大专";
								} else if (data.customer.educationBackground == 1) {
									educationBackground = "本科";
								} else if (data.customer.educationBackground == 2) {
									educationBackground = "硕士";
								} else if (data.customer.educationBackground == 3) {
									educationBackground = "博士";
								} else if (data.customer.educationBackground == 4) {
									educationBackground = "其他";
								}
								if (data.customer.customerSource == 0) {
									customerSource = "公海池";
								} else if (data.customer.customerSource == 1) {
									customerSource = "市场活动";
								} else if (data.customer.customerSource == 2) {
									customerSource = "录入客户";
								}
								$("#customerName").html(
										data.customer.customerName);
								$("#sex").html(data.customer.sex);
								$("#mobileNumber").html(
										data.customer.mobileNumber);
								$("#address").html(data.customer.address);
								$("#profession").html(data.customer.profession);
								$("#company").html(data.customer.company);
								$("#companySite")
										.html(data.customer.companySite);
								$("#birthday").html(
										new Date(data.customer.birthday)
												.toLocaleDateString());
								$("#birthPlace").html(data.customer.birthPlace);
								$("#idNumber").html(data.customer.idNumber);
								$("#phone").html(data.customer.phone);
								$("#facsimile").html(data.customer.facsimile);
								$("#url").html(data.customer.url);
								$("#createDate")	.html(
										new Date(data.customer.createDate)
												.toLocaleDateString());
								$("#maritalStatus").html(maritalStatus);
								$("#idType").html(idType);
								$("#customerType").html(customerType);
								$("#educationBackground").html(
										educationBackground);
								$("#customerSource").html(customerSource);
							}
						}
					}
				});
	}
	
			
	//拜访
	function visitOpen(id) {
		window.location.href="public_client.do?path=client_visit_detailed&id="+id;
	}	
	//跟进
	function recordOpen(id) {
		window.location.href="public_client.do?path=client_follow_detailed&id="+id;
	}	
	//合同
	function contractOpen(id) {
		window.location.href="public_client.do?path=client_contract_detailed&id="+id;
	}	
	//回款
	function receivableOpen(id) {
		window.location.href="public_client.do?path=client_receivable_detailed&id="+id;
	}
	//回访
	function revisitOpen(id) {
		window.location.href="public_client.do?path=client_revisit_detailed&id="+id;
	}

	function toDate(data) {
		var date = new Date(data);
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		m = m < 10 ? '0' + m : m;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		return y + '-' + m + '-' + d;
	}
	/**
	 *转换金钱100,000.00 
	 */
	function formatCurrency(num) {
		if (num != null && num != "") {
			num = num.toString().replace(/\$|\,/g, '');
			if (isNaN(num))
				num = "0";
			sign = (num == (num = Math.abs(num)));
			num = Math.floor(num * 100 + 0.50000000001);
			cents = num % 100;
			num = Math.floor(num / 100).toString();
			if (cents < 10)
				cents = "0" + cents;
			for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
				num = num.substring(0, num.length - (4 * i + 3)) + ','
						+ num.substring(num.length - (4 * i + 3));
			return (((sign) ? '' : '-') + num + '.' + cents);
		}
	}
</script>
</html>